package au.edu.unsw.editingtool.db;

import java.sql.SQLException;
import java.util.Hashtable;

import au.edu.unsw.editingtool.global.EditingToolException;

public class DBUser extends DBManager {
	
	private void setupDBMapping() {
		if (MappingTable.size() > 0)
			return;
		MappingTable.put("UserID", "aid");
		MappingTable.put("LastName", "lastName");
		MappingTable.put("OtherNames", "otherNames");
		MappingTable.put("Title", "title");
		MappingTable.put("PreferedLastName", "preferLastName");
		MappingTable.put("PreferedOtherNames", "preferOtherNames");
		MappingTable.put("Email", "email");
	}
	
	public DBUser() {
		this.table = "user";
		this.primaryKeys = new String[]{"UserID"}; 
		this.setupDBMapping();
	}
	
	public void addUser(Hashtable<String, String> userInfo) throws EditingToolException, ClassNotFoundException, SQLException {
		this.setTable(this.table, "");
		this.setColumnValues(userInfo);
		
		this.initDB();
		this.insert(false, true);
		this.clean();
	}
	
	
}
